package bikeAD;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.text.SimpleDateFormat;
import java.util.Date;

public class test0005_bind_order_vehicle extends getClassName {

    @Before
    public void before() {
        System.out.println(getClassName()+"开始执行……");
    }

    @After
    public void after() {
        System.out.println(getClassName()+"执行完毕……");
        System.out.println();
    }

    @Test
    public void test_bind_order_vehicle(){
        //定义管理员的手机号
        String phoneNum = "13066889177";
        common_utils commom = new common_utils();
        String order_id = commom.add_order_return_orderID(phoneNum);
        String user_token = commom.login_return_token(phoneNum);

        //新建一个日期类对象，获取当前的时间戳
        Date nowTime=new Date();
        SimpleDateFormat time=new SimpleDateFormat("yyyyMMddHHmmss");
        String curTime=time.format(nowTime);

        //广告id
        String ad_id = "ofo-xxktest" + curTime;
        System.out.println("ad_id = " + ad_id);

        //确认收货
        String graphql = "mutation{\n  deliveried_sale_order(\n    sale_order_id:\""+order_id+"\",\n    ad_id:\""+ad_id+"\"\n  )\n}";
        graphql_method method = new graphql_method();
        method.graphql_post_with_token(graphql, user_token);

        //车辆编号
        String vehicle_no = "http://ofo.so/plate/" + curTime;
        System.out.println("原始车辆编号vehicle_no = " + vehicle_no);

        //扫码安装
        String graphql2 = "mutation{\n\tbind_sale_order_vehicle(\n    sale_order_id:\""+order_id+"\",\n    vehicle_no:\""+vehicle_no+"\"\n  )\n}";
        method.graphql_post_with_token(graphql2, user_token);
    }
}
